package com.lz.football.module.leagueMatch.item
{
	import com.common.utils.DisplayObjectUtil;
	import com.common.utils.Reflection;
	import com.liangzhong.constants.TipsConst;
	import com.liangzhong.model.AppData;
	import com.liangzhong.model.club.vo.NpcClubInfoVo;
	import com.liangzhong.model.club.vo.TeamIconVo;
	import com.lz.football.module.base.IComponent;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import lz.controls.ImageContain;
	import lz.controls.LItem;
	import lz.controls.managers.TipsManager;

	/**
	 *冠军赛item 
	 * @author lake
	 * 
	 */	
	public class ChampionItem extends LItem implements IComponent
	{
		/**
		 *数组索引 
		 */		
		public var index			:int;
		/**
		 *tip显示 
		 */		
		private var tipObj    		:Object ;
		/**
		 *队徽容器 
		 */		
		private var container 		:Sprite;;
		/**
		 *队徽容器 
		 */		
		private var _image 		:ImageContain;
		
		public function ChampionItem()
		{
			super();
		}
		/**
		 *获取设置数据 
		 * @return 
		 * 
		 */		
		override public function get data():*
		{
			return super.data;
		}
		override public function set data(value:*):void
		{
			super.data = value;
			var fIndex :int = _data.status;
			_symbolSkin.gotoAndStop(fIndex);
			var npcClubVo :NpcClubInfoVo = AppData.getInstance().npcClubManager.getNpcClubById(_data.gcid);
			if(npcClubVo != null)
			{
				tipObj = {};
				tipObj.desc = npcClubVo.descplay;
				tipObj.name = npcClubVo.name;
				tipObj.starIds = npcClubVo.starIds;
				tipObj.teamUrl = npcClubVo.url_125;
				tipObj.level = (npcClubVo.level / 10);
			}
			if(fIndex == 1)
			{
				_symbolSkin.mc.txtScore.text = _data.hgoal + ":" + _data.ggoal;
			}
			else if(fIndex == 2)
			{
				_symbolSkin.mc.flagMc.gotoAndStop((index + 1));
			}
			else if(fIndex == 3)
			{
				_symbolSkin.mc.flagMc.gotoAndStop((index + 1));
			}
			if(fIndex == 1 || fIndex == 2)
			{
				if(npcClubVo)
				{
					_symbolSkin.mc.txtName.text = "" + npcClubVo.name;
				}
				if(_image == null)
				{
					_image = new ImageContain();
					_image.setSize(60,60);
					_image.url = npcClubVo.url_60;
				}
				DisplayObjectUtil.removeAllChildren(container);
				container.addChild(_image);
				_symbolSkin.mc.addChild(container);
				container.x = 12;
				container.y = 7;
			}
		}
		/**
		 *初始化 
		 */	
		public function initUI(view:Object=null):void
		{
			_symbolSkin = view as MovieClip;
			_symbolSkin.mouseChildren = false;
			container = new Sprite();
			addEvtListener();
		}
		/**
		 *注册事件 
		 */
		public function addEvtListener():void
		{
			_symbolSkin.addEventListener(MouseEvent.ROLL_OVER,onOverHandler);
			_symbolSkin.addEventListener(MouseEvent.ROLL_OUT,onOutHandler);
		}
		/**
		 * 移上
		 * @param e
		 * 
		 */		
		protected function onOverHandler(e :MouseEvent):void
		{
			if(_data == null || tipObj == null || _data.status == 3)
			{
				return;
			}
			TipsManager.show(TipsConst.TEAMINFOTIPS,tipObj,15,15,true,true);
		}
		/**
		 * 移出
		 * @param e
		 * 
		 */		
		protected function onOutHandler(e :MouseEvent):void
		{
			TipsManager.hide();
		}
		/**
		 *删除事件 
		 */
		public function removeEvtListener():void
		{
			_symbolSkin.removeEventListener(MouseEvent.ROLL_OVER,onOverHandler);
			_symbolSkin.removeEventListener(MouseEvent.ROLL_OUT,onOutHandler);
		}
		/**
		 *销毁 
		 */	
		public function destroyView():void
		{
			removeEvtListener();
			if(_image)
			{
				_image.clear();
				_image = null;
			}
		}
	}
}